import React, {useLayoutEffect, useRef} from "react";

const AutoHeight = (props: {
    setHeight: (value: number) => void,
    style?: React.CSSProperties,
    children: any
}) => {
    const ref = useRef<any>(null);
    useLayoutEffect(() => {
        props.setHeight(ref.current.clientHeight);
    }, [props]);
    return (<div ref={ref} style={{...props.style, height: "100%"}}>
        {props.children}
    </div>)
}
export default AutoHeight